package com.zego.wawaji.wawaji_client.util;

import android.view.View;

import com.zego.wawaji.ui.play.PlayHelper;

import java.util.Calendar;

/**
 * 带音效按钮点击
 * Created by Su on 2017/11/30.
 */
public abstract class OnSoundClickListener implements View.OnClickListener {
    // 连续两次点击之间的时间间隔
    public static final int MIN_CLICK_DELAY_TIME = 300;

    // 上一次的点击时间
    private long lastClickTime = 0;

    @Override
    public void onClick(View v) {
        long currentTime = Calendar.getInstance().getTimeInMillis();
        if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
            lastClickTime = currentTime;
            onSoundClick(v);
            PlayHelper.playBtnSound();
        }
    }

    public abstract void onSoundClick(View v);
}
